package com.dgut.service.background.dao;

import com.dgut.service.background.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserDao extends PagingAndSortingRepository<User, Integer> {
    Page<User> findByNameLike(String name, Pageable pageable);

    @Query("select u.openid from User u where u.name = :username")
    List<String> findOpenidByName(@Param("username") String username);

    User findUserByOpenid(String openId);

    User findByUserId(int userId);

    List<User> findAll();
}
